package svgedit.japangui.actions;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;

import svgedit.japangui.JapanFrame;
import svgedit.svg.SVGElement;

/** Deletes all selected elements.
 *
 */
@SuppressWarnings("serial")
public class DeleteAction extends AbstractAction {

    private JapanFrame japanFrame;

    /** Create this action for the given frame */
    public DeleteAction(JapanFrame japanFrame) {
        super("\u524A\u9664");
        this.japanFrame = japanFrame;
    }

    public void actionPerformed(ActionEvent ae) {
        for (SVGElement elem : japanFrame.getView().getSelectedElements())
            elem.getParent().removeChild(elem);
        japanFrame.getDocument().setModified(true);
        japanFrame.getView().clearSelection();
        japanFrame.repaint();
    }

}
